package misc;

public class Clock {

	
	private static double[] clock = {1,0.875,0.75,0.625,0.5,0.375,0.25,0.125};
	
	public static void print(double change){
		System.out.println("CHANGE:"+change);
		System.out.println("\t\t"+magic(clock[2],change)+"("+clock[2]+")");
		System.out.println("\t"+magic(clock[3],change)+"("+clock[3]+")"+"\t\t"+magic(clock[1],change)+"("+clock[1]+")");
		System.out.println(magic(clock[4],change)+"("+clock[4]+")"+"\t\t\t\t"+magic(clock[0],change)+"("+clock[0]+")");
		System.out.println("\t"+magic(clock[5],change)+"("+clock[5]+")"+"\t\t"+magic(clock[7],change)+"("+clock[7]+")");
		System.out.println("\t\t"+magic(clock[6],change)+"("+clock[6]+")");
		System.out.println();
	}

	private static double magic(double ori, double offset){
		double x = (offset-ori)*2, sign = Math.signum(x), range=Math.signum(x-sign);
		return x-(range+sign)*range*sign;
	}
	
	public static void printAll(){
		print(0);
		for(double change : clock){
			print(change);
		}
	}
	
}
